﻿@using Hetang.Models.ControlExtensions
@model Hetang.Models.DataContext.tbl_Company
@{
    ViewBag.Title = "企业基本信息设置";
    ViewBag.SettingTitle = Model == null ? "创建企业基本信息" : "修改企业基本信息";
    ViewBag.Required = true;
    Layout = "~/Views/Shared/_UserLayout.cshtml";
}

<div class="bs-docs-grid">
    @if (Model == null)
    {
        <div class="alert fade in" style="width:750px;">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
            <strong>提示!</strong> 你还没有创建你的企业基本信息，马上填写基本信息让其它企业更加了解你的企业！
        </div>
    }
    @if (ViewBag.Info != null)
    {
        <div class="alert alert-success fade in auto-hidden" style="width:750px;">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
            <strong>@ViewBag.Info</strong>
        </div>
    }
    @if (ViewBag.Error != null)
    {
        <div class="alert alert-error fade in" style="width:750px;">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
            <strong>@ViewBag.Error</strong>
        </div>
    }
    <div class="row show-grid">
        <div class="span12">
            @using (Html.BeginForm("index", "company", FormMethod.Post, new { @class = "form-horizontal" }))
            {
                <div class="control-group">
                    @Html.LabelFor(model => model.Name, new { @class = "control-label", important = "*" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.Name, new { maxlength = 16 })
                        @Html.ValidationMessageFor(model => model.Name)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.Trade, new { @class = "control-label", important = "*" })
                    <div class="controls">
                        @{
                Hetang.Models.Interface.IConfigRepository _cr = new Hetang.Models.Repository.ConfigRepository();
                List<SelectListItem> Trade = _cr.GetCompanyTrade();
                        }
                        @Html.DropDownListFor(model => model.Trade, Trade, new { @style = "width:270px" })
                        @Html.ValidationMessageFor(model => model.Trade)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.Unit_character, new { @class = "control-label", important = "*" })
                    <div class="controls">
                        @{
                List<SelectListItem> unit = new List<SelectListItem>()
    {
        new SelectListItem{Text = "民营企业",Value="民营企业"},
        new SelectListItem{Text = "私营企业",Value="私营企业"},
        new SelectListItem{Text = "三资企业",Value="三资企业"},
        new SelectListItem{Text = "社会团体",Value="社会团体"},
        new SelectListItem{Text = "股份制企业",Value="股份制企业"},
        new SelectListItem{Text = "事业单位",Value="事业单位"},
        new SelectListItem{Text = "外资企业",Value="外资企业"},
        new SelectListItem{Text = "其它",Value="其它"}
    };
                        }
                        @Html.DropDownListFor(model => model.Unit_character, unit)
                        @Html.ValidationMessageFor(model => model.Unit_character)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.Registered_Capital, new { @class = "control-label", important = "*" })
                    <div class="controls">
                        @{
                List<SelectListItem> Capital = new List<SelectListItem>() { 
        new SelectListItem{Text = "保密",Value="0"},
        new SelectListItem{Text = "10万以下",Value="1"},
        new SelectListItem{Text = "10万-100万以下",Value="2"},
        new SelectListItem{Text = "100万-500万",Value="3"},
        new SelectListItem{Text = "500万-1000万",Value="4"},
        new SelectListItem{Text = "1000万-5000万",Value="5"},
        new SelectListItem{Text = "5000万以上",Value="6"}
    };
                        }
                        @Html.DropDownListFor(model => model.Registered_Capital, Capital)
                        @Html.ValidationMessageFor(model => model.Registered_Capital)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.Employees, new { @class = "control-label" })
                    <div class="controls">
                        @{
                List<SelectListItem> Employees = new List<SelectListItem>() { 
        new SelectListItem{Text="50人以下",Value="0"},
        new SelectListItem{Text="50-100人",Value="1"},
        new SelectListItem{Text="100-200人",Value="2"},
        new SelectListItem{Text="200-500人",Value="3"},
        new SelectListItem{Text="500-1000人",Value="4"},
        new SelectListItem{Text="1000人以上",Value="5"}
    };
                        }
                        @Html.DropDownListFor(model => model.Employees, Employees)
                        @Html.ValidationMessageFor(model => model.Employees)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.Founding_Time, new { @class = "control-label", important = "*" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.Founding_Time, new { maxlength = 10 })<span class="help-inline">格式：2013-01-01</span>
                        @Html.ValidationMessageFor(model => model.Founding_Time)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.Contacts, new { @class = "control-label", important = "*" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.Contacts, new { maxlength = 10 })
                        @Html.ValidationMessageFor(model => model.Contacts)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.QQ, new { @class = "control-label" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.QQ, new { maxlength = 11 })
                        @Html.ValidationMessageFor(model => model.QQ)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.Phone, new { @class = "control-label", important = "*" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.Phone, new { maxlength = 13 })
                        @Html.ValidationMessageFor(model => model.Phone)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.Fax, new { @class = "control-label" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.Fax, new { maxlength = 13 })
                        @Html.ValidationMessageFor(model => model.Fax)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.Address, new { @class = "control-label", important = "*" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.Address, new { @class = "textbox-longer" })
                        @Html.ValidationMessageFor(model => model.Address)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.Website, new { @class = "control-label" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.Website, new { @class = "textbox-longer" })
                        @Html.ValidationMessageFor(model => model.Website)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.Introduce, new { @class = "control-label", important = "*" })
                    <div class="controls">
                        @Html.TextAreaFor(model => model.Introduce, new { @class = "only-vertical-resize textbox-longer", @rows = "15" })
                        @Html.ValidationMessageFor(model => model.Introduce)
                    </div>
                </div>
                
                <div class="control-group">
                    <div class="controls">
                        <button type="submit" class="cbtn cbtn-info cbtn-large">保存</button>
                    </div>
                </div>
            }
        </div>
    </div>
</div>

@Html.GetJavascript("jquery.validate.min.js")
@Html.GetJavascript("jquery.validate.unobtrusive.min.js")

<script type="text/javascript">
    $("#Founding_Time").keyup(function () {
        if ($(this).val().length == 4) {
            $(this).val($(this).val() + "-");
        }
        else if ($(this).val().length == 7) {
            $(this).val($(this).val() + "-");
        }
    });    
</script>
